const fs = require('fs')

const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')

const dataBaseDir = 'E:/code/electron/dream/src/data/'

const db = low(new FileSync(`${dataBaseDir}/movie.json`))

const movies = db.read()
    .get('movies')
    .value()

let videoCount = 0

for (let movie of movies) {
    const star = movie.star ? `${movie.star}/` : ''
    const videoRootDir = `${movie.rootDir}${star}${movie.year}.${movie.name}/`
    for (let dreamVideo of movie.dreamVideos) {
        videoCount++
        const video = `${videoRootDir}${dreamVideo.video}`
        if (!fs.existsSync(video)) {
            console.log(videoCount, video)
        }
    }
}

console.log(videoCount)
